<%-- 
    Document   : gen_report_on_AllOrders
    Created on : May 3, 2013, 7:36:12 PM
    Author     : Ivchenko Oleg, Svetlana Shikhutskaya
--%>
<%@page import="java.util.Iterator"%>
<%@page import="entity.Users"%>
<%@page import="java.util.AbstractList"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="javax.faces.convert.BigDecimalConverter"%>
<%@page import="entity.Orders"%>
<%@page import="entity.Warehouse"%>
<%@page import="entity.Users"%>
<%@page import="facade.OrdersFacadeLocal"%>
<%@page import="facade.WarehouseFacadeLocal"%>
<%@page import="facade.UsersFacadeLocal" %>
<%@page import="java.util.List"%>
<%@page import="javax.naming.NamingException"%>
<%@page import="javax.naming.InitialContext"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%! private WarehouseFacadeLocal warehouseFacade;
    private UsersFacadeLocal usersFacade;
    private OrdersFacadeLocal ordersFacade;
    private Users user;

    public void jspInit() {
        try {
            InitialContext ic = new InitialContext();
            ordersFacade = (OrdersFacadeLocal) ic.lookup("java:global/Delta/Delta-ejb/OrdersFacade!facade.OrdersFacadeLocal");
            warehouseFacade = (WarehouseFacadeLocal) ic.lookup("java:global/Delta/Delta-ejb/WarehouseFacade!facade.WarehouseFacadeLocal");
            usersFacade = (UsersFacadeLocal) ic.lookup("java:global/Delta/Delta-ejb/UsersFacade!facade.UsersFacadeLocal");
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
    }
%>
<%
    List<Warehouse> warehouses = warehouseFacade.findAll();
    List<Users> users = usersFacade.findAll();
    List<Orders> orders = ordersFacade.findAll();
%>
<%user = (Users) session.getAttribute("user");
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/styl.css">
         <link rel="stylesheet" type="text/css" href="css/all.css">
        <link rel="stylesheet" type="text/css" href="css/gen_reports.css">
        <script type="text/javascript" src="scripts/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="scripts/general-report.js"></script>

        <!-- script links for datepicker-->

        <!--<link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css" />-->
        <script src="js/jquery-ui.js"></script>
        <link rel="stylesheet" href="js/jquery-ui.css" />
        <script>
            $(function() {
                $( ".calendar" ).datepicker();
                //$("#datepicker").datepicker();
            });
        </script>
        <title>Generation report on shipment orders</title>
    </head>
    <body onload="loadOrders()">
        <header>
            <div id ="top_name"> <a href="main.jsp">  <img src="/Delta-war/product/1.jpeg"> </a> <h1> Warehouse employee</h1> </div>
           
            <div id="registr2">
                <p> <a href="user_name.jsp"><%=user.getLogin()%> </a>
                    <a href="logout">LogOut</a> </p>
            </div>
            <div id="menu">
                <div id="line"> <a href="WarehouseOrders"> Orders</a> </div>
                <div id="line"> <a href="warehouse.jsp"> Warehouses</a> </div>
                <div id="line"> <a href="catalog_product.jsp"> Product</a> </div>
                <div id="line" style="background: #32CD32"> <a href=""></a>Report</div>
            </div>
        </header>
        <div id="main">
            <form method="post" action="general_report.jsp">
                <div id="line_button">
                                    
                        Status
                        <select
                            name="status"
                            size=1
                            id="select-status"
                            onchange="init()">
                            <option value="all" selected>all</option>
                            <% for (String status : ordersFacade.getListStatuses()) {%>
                            <option value="<%=status%>"><%=status%></option>
                            <%}%>
                        </select> 
                                   </div>
                 <div id="line_button">
                    Warehouse
                        <select  
                            id="select-warehouse"
                            name="warehouse" 
                            size = 1
                            onchange="init()">
                            <option value="0" selected>all</option>
                            <% for (Warehouse w : warehouses) {%>
                            <option value="<%=w.getIdWarehouse()%>"><%=w.getName()%></option>
                            <%}%>
                        </select> 
                    
                </div>
               <div id="line_button">  User
                        <select  
                            id="select-user"
                            name="user" 
                            size = 1
                            onchange="init()">
                            <option value="0" selected>all</option>
                            <% for (Users user : users) {%>
                            <option value="<%=user.getIdUser()%>"><%=user.getFirstName() + ' ' + user.getLastName()%></option>
                            <%}%>
                        </select>
                </div>
                
                     <div id="start">   Start date: <input 
                            class="calendar" 
                            type="text" 
                            id="datepickerStart"
                            onchange="init();"/><br>
                     </div>
                       <div id="finish"> End date: <input 
                            type="text" 
                            class="calendar" 
                            id="datepickerEnd"
                            onchange="init();"/>
                    </p>
                </div>
            </form>
        
        <div id="tabl4">
            <form id ="tabl">
                <p>Orders:</p>
                <table class="table-orders" width="90%">
                    <TR>
                        <td id="head_table_first">Order #</td>
                        <td id="head_table_first">Order Date</td>
                        <td id="head_table_first">Order Status</td>
                        <td id="head_table_first">Warehouse</td>
                        <td id="head_table_first">User</td>
                        <td id="head_table_first">Address</td>
                        <td id="head_table_first">Shipping price</td>
                        <td id="head_table_first">Product price</td>
                    </TR>
                </table>
            </form>
        </div>
        <div id="paging">
            <div id="line_button3"> 
                <button
                    class="left-page"
                    id="cross" 
                    name="back">
                    << 
                </button>
                <span style="font-size: 14px" id="num"></span>
            </div>

            <div id="line_button3"> 
                <button
                    class="right-page"
                    id="cross" 
                    name="forward">
                    >>
                </button><br>
            </div>
            <div id="expExcel"> 
                <form method="POST">   
                    <button id="repGen"
                            class="export-exel"
                            type="submit" 
                            name="export"
                            >
                        Export to Excel
                    </button>
                </form>
            </div>
        </div>
                         <div id="footer">
                                <p>  &#169;All rights reserved</p>
                            </div>
    </body>
</html>
